import 'package:demo1223/service/service_method.dart';
import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import '../../provide/detailsDats.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_html/flutter_html.dart';






class DerailsWeb extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var goodsDetails =
        Provide.value<DetailsInfoProvide>(context).goodsinfo.data.description;
    List<Map> evaData = (Provide.value<DetailsInfoProvide>(context)
            .evalistsData['data'] as List)
        .cast();
    print(evaData);
    return Provide<DetailsInfoProvide>(
      builder: (context, child, val) {
        var isLeft = Provide.value<DetailsInfoProvide>(context).isLeft;
        if (isLeft) {
          return Container(
            margin: EdgeInsets.only(bottom: 150),
            child: Html(
              data: goodsDetails,
            ),
          );
        } else {
          return Container(
            width: ScreenUtil().setWidth(750),
            padding: EdgeInsets.all(10.0),
            child: Column(
              children: <Widget>[
                // _user(evaData),
                _usercontent(evaData),
              ],
            ),
          );
        }
      },
    );
  }

  Widget _usercontent(data) {
    final evaData = data;
    return Container(
      height: ScreenUtil().setHeight(200),
      child: ListView.builder(
          itemCount: evaData.length,
          physics: BouncingScrollPhysics(),
          itemBuilder: (context, index) {
            return Container(
              // height: ScreenUtil().setHeight(100.0),
              // width: ScreenUtil().setWidth(750),
              child: Column(
                children: <Widget>[
                  _user('${evaData[index]['avatar']}','${evaData[index]['nick_name']}','${evaData[index]['create_time']}'),
                  _usera('${evaData[index]['evl_content']}')
                ],
              ),

            );
          }),
    );
  }

  Widget _usera(comment) {
    return Container(
      // margin: EdgeInsets.only(right: 250),
      alignment: Alignment.centerLeft,
      margin: EdgeInsets.only(top: 10),
      child: Column(
        children: <Widget>[
          Text(comment)
        ],
      ),
    );
    
  }
  
  Widget _user(img,name,time){
    return Row(
      children: <Widget>[
        _userimg(img),
        _userinformation(name,time),
      ],
    );
  }
  Widget _userimg(imgs){
    return CircleAvatar(
      radius: 20,
      backgroundImage: NetworkImage(
        imgs,
      ),
      
    );
  }


  Widget _userinformation(name,time){
      return Container(
        margin: EdgeInsets.only(left: 10),
        child: Column(
        children: <Widget>[
          Text(
            name,
          ),
          Text(
            time,
            style: TextStyle(color: Colors.black38),
          )
        ],
      )
      );
  }

}
